import 'dart:convert';
import 'dart:io';
import 'dart:async';

class API {
  // uranus APIs
  static const String DOMIN = "db.manaai.cn";
  // static const String DOMIN = "192.168.0.104";
  // static const String DOMIN = "localhost";
  // static const String DOMIN = "192.168.100.153";
  // static const String DOMIN = "192.168.125.28";
  // static const String BASE_URL = "http://$DOMIN:9000";
  static const String BASE_URL = "http://$DOMIN";

  static const String WS_URL = "ws://$DOMIN/v1/ws";
  static const String WS2_URL = "ws://$DOMIN/v1/ws2";

  static const String MANA_HOST = "http://home.manaai.cn";

  static const String LOGIN_URL = "$BASE_URL/api/v2/users_login";
  static const String USERS_URL = "$BASE_URL/api/v2/users";
  static const String USERS2_URL = "$BASE_URL/api/v2/users2";
  static const String USERS_EDIT = "$BASE_URL/api/v2/users_edit";

  static const String FIND_USER_URL = "$BASE_URL/api/v2/find_user";
  static const String FIND_USER_BY_ADDR = "$BASE_URL/api/v2/find_user_by_addr";
  static const String USER_REGISTER_TMP = '$BASE_URL/api/v2/users_register_tmp';

  static const String SET_URANUS_VIPS = "$BASE_URL/api/v2/open_vip";
  static const String GET_ALL_USERS_URANUS = "$BASE_URL/api/v2/get_all_users";

  // pgyer's API updates url
  // POST: _api_key: 81b426570d1330dba8bf6512ea830cbc	String, appKey: 17148e6acd9775d77da183dc549bc9ed, buildVersion, buildBuildVersion
  // curl -d "_api_key=81b426570d1330dba8bf6512ea830cbc&appKey=17148e6acd9775d77da183dc549bc9ed&buildBuildVersion=1" https://www.pgyer.com/apiv2/app/check
  static const String APP_UPDATE_CHECK =
      "https://www.pgyer.com/apiv2/app/check";

  // Tasks sync API
  static const String UPDATE_TASKS_URL =
      "$BASE_URL/api/v2/daybreak_update_tasks";
  static const String UPDATE_PROJECT_URL =
      "$BASE_URL/api/v2/daybreak_update_project";
  static const String LOAD_TASKS_UPDATE_URL =
      "$BASE_URL/api/v2/daybreak_load_tasks_update";
  // update single tasks
  static const String GET_TASKS_UPDATE_URL =
      "$BASE_URL/api/v2/daybreak_update_tasks";
  static const String DELETE_TASKS_URL =
      "$BASE_URL/api/v2/daybreak_delete_tasks";
  static const String DELETE_PROJECTS_URL =
      "$BASE_URL/api/v2/daybreak_delete_projects";
  static const String SYNC_TASKS_SIM_URL =
      "$BASE_URL/api/v2/daybreak_sync_tasks_sim";
  static const String SYNC_PROJECTS_URL =
      "$BASE_URL/api/v2/daybreak_sync_projects";
  static const String SYNC_PROJECTS_SIM_URL =
      "$BASE_URL/api/v2/daybreak_sync_projects_sim";
  static const String SYNC_LABELS_URL = "$BASE_URL/api/v2/daybreak_sync_labels";

  static const String GET_SHARED_TASKS_URL =
      "$BASE_URL/api/v2/daybreak_get_tasks_shared";
  static const String SET_SHARED_TASKS_URL =
      "$BASE_URL/api/v2/daybreak_set_tasks_shared";

  static const String ADD_TASKS_LOOK_OR_LIKE =
      "$BASE_URL/api/v2/daybreak_tasks_look_or_like";

  static const String GET_TASKS_USERS =
      "$BASE_URL/api/v2/daybreak_get_tasks_users";
  static const String ADD_USER_TO_TASK =
      "$BASE_URL/api/v2/daybreak_add_user_to_tasks";
  static const String GET_SHARED_IDEAS_URL =
      "$BASE_URL/api/v2/daybreak_get_ideas_shared";

  ///////////////// User related API /////////////////////
  static const String FIND_USER = "$BASE_URL/api/v2/find_user";

  //////////// Tasks comments related API /////////////
  static const String COMMENT_TO_TASKS =
      "$BASE_URL/api/v2/daybreak_comment_to_tasks";
  static const String GET_TASKS_COMMENTS =
      "$BASE_URL/api/v2/daybreak_get_tasks_comments";
  //////////// taks comments end ///////////////////

  static const String URANUS_STATISTICS = "$BASE_URL/api/v2/uranus_statistic";
  static const String DAYBREAK_GET_LEADERBOARD =
      "$BASE_URL/api/v2/daybreak_get_leaderboard";

  ///////////////////// Below APIS not using for now ///////////////////////
  static const String testContactsUrl = "$BASE_URL/api/v2/test_contacts";
  static const String searchUserUrl = "$BASE_URL/api/v2/users";
  static const String sessionsUrl = "$BASE_URL/api/v2/sessions";
  static const String suggestUserUrl = "$BASE_URL/api/v2/suggest_users";

  static const String globalSessionsUrl = "$BASE_URL/api/v2/sessions";
  static const String globalTimelineUrl = "$BASE_URL/api/v2/timeline";

  //////////// Colibri related API ///////////////////////
  static const String COLIBRI_GET_LOGIN_INFOS =
      "$BASE_URL/api/v2/get_login_infos";

  static const String COLI_DEL_USER = "$BASE_URL/api/v2/del_user";
  static const String COLI_GET_ALL_USERS = "$BASE_URL/api/v2/get_all_users";
  static const String COLI_GET_FRIENDS = "$BASE_URL/api/v2/friends";
  static const String COLI_BAND_USER = "$BASE_URL/api/v2/band_user";
  static const String COLI_LIMIT_USER = "$BASE_URL/api/v2/limit_user";

  static const String globalImagesUploadUrl =
      "http://$DOMIN/api/v1/image_upload_outside";
// vendor API
  static const String globalImageUploadSMSUrl = "https://sm.ms/api/upload";

  static const String globalTimeLineCommentUrl =
      "$BASE_URL/api/v2/timeline_comment";
  static const String globalTimeLineCommentReplyUrl =
      "$BASE_URL/api/v2/timeline_comment_reply";
  String globalTimeLineCommentLikeUrl =
      "$BASE_URL/api/v2/timeline_comment_like";

// post or get friends, post: request or approval
  static const String globalFriendsUrl = "$BASE_URL/api/v2/friends";
  static const String globalFriendsRequestUrl =
      "$BASE_URL/api/v2/friends_requests";
  static const String globalIsFriendsUrl = "$BASE_URL/api/v2/is_friends";

// Adding create group relate apis
  static const String globalCreateGroupUrl = "$BASE_URL/api/v2/create_group";
  static const String globalGetAllGroupUrl = "$BASE_URL/api/v2/all_groups";
  static const String globalGetGroupAllMembersUrl =
      "$BASE_URL/api/v2/get_group_subscribers";
  static const String globalAddMemberToGroupUrl =
      "$BASE_URL/api/v2/add_subscriber_to_group";
  static const String globalAllOpenGroups = "$BASE_URL/api/v2/all_open_groups";

// urls for anonymous post and user anonymous info
// post, get, del
  static const String globalAnonymousPost = "$BASE_URL/api/v1/anonymous";
  static const String globalAnonymousCommentsPost =
      "$BASE_URL/api/v1/anonymous_comment";
  static const String globalAnonymousLike = "$BASE_URL/api/v1/anonymous_like";
  static const String globalAnonymousReplyComments =
      "$BASE_URL/api/v1/anonymous_comment_reply";
  static const String globalUpdateUserAnonymousInfo =
      "$BASE_URL/api/v1/update_user_anonymous_info";

  static const String gGetAllUsersUrl = "$BASE_URL/api/v2/get_all_users";
  static const String gDelUserUrl = "$BASE_URL/api/v2/del_user";
  static const String gBandUserUrl = "$BASE_URL/api/v2/band_user";
  static const String gLimitUserUrl = "$BASE_URL/api/v2/limit_user";
  static const String gTimelineUserAddrUrl =
      '$BASE_URL/api/v2/timeline_user_addr';

  ////////////////////////// APIS for Nirvana Platform ////////////////////
  static const String MANA_USERS_GET = MANA_HOST + "/api/v2/get_all_users";
  static const String MANA_USERS_URL = MANA_HOST + "/api/v2/users";
  static const String MANA_USERS_LOGIN = MANA_HOST + "/api/v2/login";
  static const String URANUS_STATISTIC = BASE_URL + "/api/v2/uranus_statistic";

  // set vip
  static const String SET_MANA_VIP = MANA_HOST + "/api/v2/set_user_manavip";
  static const String USER_GET_BY_ID = MANA_HOST + "/api/v2/get_user_by_id";
  static const String MANA_USERS_SUMMARY = MANA_HOST + "/api/v2/users_summary";
  // search user
  static const String SEARCH_MANA_USER =
      MANA_HOST + "/api/v2/search_user_email";
}
